<?php

/**
 * Project form base class.
 *
 * @package    wildlive
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormBaseTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
abstract class BaseFormDoctrine extends sfFormDoctrine {
	public function setup() {
	}
	
	protected function __unsetSimpleChangeTrackerFields() {
		unset ( $this ['created_at'], $this ['updated_at'], $this ['deleted_at'], $this ['created_by'], $this ['updated_by'], $this ['deleted_by'], $this ['slug'] );
	}
	
	/**
	 * Workaround for not having embedded forms inserted twice
	 * @see http://trac.symfony-project.org/ticket/4935
	 * @see lib/vendor/symfony/lib/form/addon/sfFormObject#updateObject()
	 */
	public function updateObject($values = null) {
		if (null === $values) {
			$values = $this->values;
		}
		
		$values = $this->processValues ( $values );
		
		$objectValues = $values;
		foreach ( $this->embeddedForms as $name => $embeddedForm ) {
			if (array_key_exists ( $name, $values )) {
				unset ( $objectValues [$name] );
			}
		}
		
		$this->doUpdateObject ( $objectValues );
		
		$this->updateObjectEmbeddedForms ( $values );
		
		return $this->getObject ();
	}
}
